
/**
 * 打日志
 */
import store from '../store';
import dayjs from 'dayjs';

export default function debug(pageName = '-', message = '', data) {
  const userid = store.getters.userid || '-';
  const now = dayjs().format('YYYY-MM-DD HH:MM:SS');
  if (typeof data === 'string') {
    // #ifdef MP-WEIXIN
    wx.getLogManager().log(`====> ${userid}/${pageName}/${now} ${message}: ${data}`);
    // #endif
    console.log(`====> ${userid}/${pageName}/${now} ${message}: ${data}`);
  } else {
    // #ifdef MP-WEIXIN
    wx.getLogManager().log(`====> ${userid}/${pageName}/${now} ${message}: ${JSON.stringify(data)}`);
    // #endif
    console.log(`====> ${userid}/${pageName}/${now} ${message}: ${JSON.stringify(data)}`);
  }
}
